<template>
  <div class="order-list-option">
    <date-picker :date="endTime" :option="option" :limit="limit" v-model="endTime.time"></date-picker>
  </div>
</template>

<script>
import axios from 'axios'
import global from '../../utils/global'
import store from '../../utils/store'
import Datepicker from 'vue-datepicker2/vue-datepicker-es6.vue';
let moment = require('moment');
export default {
  name: "birthDate",
  components:{
    'date-picker': Datepicker
  },
  data() {
    return {
      startTime: {
        time: '',
      },
      endTime: {
        time: '1980-01-01',
        // time: this.$emit('childByValue', this.childValue),
      },
      option: {
        type: 'day',
        week: ['一', '二', '三', '四', '五', '六', '日'],
        month: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
        format: 'YYYY-MM-DD',
        placeholder: 'when?',
        inputStyle: {
          'display': 'inline-block',
          'padding': '0px',
          'font-size': '0.95rem',
          'border': '0px solid #fff',
          'border-radius': '2px',
          // 'color': '#5F5F5F',
          'color': '#000',
          'width': '100%'
        },
        color: {
          header: '#ccc',
          headerText: '#f00',
        },
        buttons: {
          ok: '确定',
          cancel: '取消',
        },
        overlayOpacity: 0.5,
        dismissible: true,
      },
      timeoption: {
        type: 'min',
        week: ['一', '二', '三', '四', '五', '六', '日'],
        month: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
        format: 'YYYY-MM-DD HH:mm'
      },
      multiOption: {
        type: 'multi-day',
        week: ['一', '二', '三', '四', '五', '六', '日'],
        month: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
        format:"YYYY-MM-DD HH:mm"
      },
      limit: [
        {
          type: Array,
          default:function _default(){
            return [];
          },
        },
        // {
        //   type: 'weekday',
        //   available: [1, 2, 3, 4, 5]
        // },
        {
          type: 'fromto',
          from: '',
          to: ''
        }
      ],
    }
  },
  mounted(){
    this.getInfo();
    // this.endTime.time = global.enter.birth;
  },
  beforeUpdate(){   //该钩子在服务器端渲染期间不被调用，因为只有初次渲染会在服务端进行。
    this.LopTime();
  },
  props: [''],
  computed: {},
  methods: {
    LopTime(){
      console.log("LopTime");
      console.log(this.endTime.time);
      // global.enter.birth = this.endTime.time;
    },
    // 获取接口信息
    getInfo(){
      var that = this;
      axios.get(global.api.order.customer.adopt,{
        params: {
          uuid: localStorage.getItem('carWashUuid'),
        }
      })
      .then(function(res){
        console.log("birthDate then");
        console.log(res);
        if (res.data.code == 0) {
          if (res.data.data.isshow == 1) {
            that.endTime.time = res.data.data.birthday
          }
        }
      })
      .catch(function(res){
        console.log("birthDate catch");
        console.log(res);
      })
    },
  },
  watch: {
    endTime: function(){
      this.$emit('childByValue', this.endTime.time)
    },
  },
}

</script>
<style scoped>
  .order-list-option{
    line-height: 2rem;
    width: 10.6rem;
    padding-left: 10px;
    border: 1px solid rgba(0,0,0,0.3);
    flex: 1;
  }
  .order-list-option>div{
    width: 100%;
  }
</style> 